home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news
- From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
- Newsgroups: comp.lang.c++
- Subject: Re: [Q] same template name with template-arg-list
- Date: Wed, 10 Jan 1996 13:50:37 +0100
- Organization: Fachbereich Informatik, TH Darmstadt
- Message-ID: <30F3B61D.1CFBAE39@intellektik.informatik.th-darmstadt.de>
- References: <whlong48ht.fsf@balder.metis.no>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b4 (X11; I; SunOS 4.1.3 sun4m)
-
- Steinar Bang wrote:
- >
- > Is it legal in the ANSI C++ draft to have something like:
- >
- > template<class T> class sequence {
- > public:
- > sequence() ;
- > };
- >
- > template<class T, int len> class sequence {
- > public:
- > sequence() ;
- > };
- >
- > and have these two be different templates?
- >
- > Same template name but different argument lists should give different
- > signatures, so I don't see any principal problem...?
- >
-
- No, it's (IMHO) not possible.
- But you can have sth. similar called 'template specialization'.
- For example the former template could be seen as specialization
- of the latter template:
-
- template<class T,int len> class sequence { ... };
- template<class T> class sequence<T,0> { ... };
-
- In this way you can provide a default-version of the template and
- one with a restricted applicability.
- This is for example usefull if the you use an inductive definition
- for a generic type, like:
-
- A n-dim. sequence is a sequence of (n-1)-dim. sequences
- A 0-sequence is a single value.
-
- Enno
-